@extends('admin.layout')

@section('content')
    <div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-permission" style="padding: 20px 30px 0 0;">
        <form action="{{route('admin.permission.store')}}" method="post">
            @include('user.permission._from')
        </form>
    </div>
@endsection

@section('js')
    <script>
        layui.config({
            base: '/static/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form'], function(){
            var $ = layui.$
                ,form = layui.form;

            /* 触发弹层 */
            var active = {
                choose: function () {
                    $.get("{{route('admin.icons')}}",function (res) {
                        if (res.code==0 && res.data.length>0){
                            var html = '<ul class="site-doc-icon">';
                            $.each(res.data,function (index,item) {
                                html += '<li onclick="chioceIcon(this)" data-id="'+item.id+'" data-class="'+item.class+'" data-name="'+item.name+'" >';
                                html += '   <i class="layui-icon '+item.class+'"></i>';
                                html += '   <div class="doc-icon-name">'+item.name+'</div>';
                                html += '   <div class="doc-icon-code"><xmp>'+item.unicode+'</xmp></div>';
                                html += '   <div class="doc-icon-fontclass">'+item.class+'</div>';
                                html += '</li>'
                            });
                            html += '</ul>';
                            layer.open({
                                type:1,
                                title:'选择图标',
                                area : ['1050px','500px'],
                                content:html
                                ,yes: function(index, layero){
                                    var icon_id = $(obj).data('id');
                                    $("input[name='icon_id']").val(icon_id);
                                    $("#icon_box").html('<i class="layui-icon '+$(obj).data('class')+'"></i> '+$(obj).data('name'));
                                    layer.closeAll();
                                }
                            })
                        }else {
                            layer.msg(res.msg);
                        }
                    },'json')
                }
            }

            $('#layuiadmin-form-permission .layui-word-aux .layui-btn').on('click', function(){
                var type = $(this).data('type');
                active[type] && active[type].call(this);
            });
        })
    </script>
    @include('user.permission._js')
@endsection
